package com.highspeed.bdk.bean.entity.physical;

import com.bianmaba.spring.data.jpa.domain.annotations.QueryCacheable;
import com.highspeed.bdk.bean.base.IncrementEntity;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;


/**
 * Created by chenjiabin on 2018/3/23.
 */
@Entity
@DynamicUpdate(true)
@DynamicInsert(true)
@QueryCacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Board extends IncrementEntity {
    @Column(nullable = false, length = 32)
    private String boardId;

    @Column(length = 32)
    private String slotNo;

    @Column(length = 64)
    private String boardName;

    @Column(length = 16)
    private Integer boardType;

    @Column(length = 16)
    private Integer boardSize;

    @Column(length = 16)
    private Integer boardModel;

    @Column(length = 32)
    private String boardSN;

    @ManyToOne(optional = false)
    @JoinColumn(name = "MachineBox_id", nullable = false)
    private MachineBox machineBox;

    @OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "board")
    private List<Cpu> cpus = new ArrayList<Cpu>(0);

    public String getBoardId() {
        return boardId;
    }

    public void setBoardId(String boardId) {
        this.boardId = boardId;
    }

    public String getMachineBoxNo() {
        if (machineBox != null) {
            return machineBox.getMachineBoxNo();
        } else {
            return null;
        }
    }


    public String getSlotNo() {
        return slotNo;
    }

    public void setSlotNo(String slotNo) {
        this.slotNo = slotNo;
    }

    public String getBoardName() {
        return boardName;
    }

    public void setBoardName(String boardName) {
        this.boardName = boardName;
    }

    public Integer getBoardType() {
        return boardType;
    }

    public void setBoardType(Integer boardType) {
        this.boardType = boardType;
    }

    public Integer getBoardSize() {
        return boardSize;
    }

    public void setBoardSize(Integer boardSize) {
        this.boardSize = boardSize;
    }

    public Integer getBoardModel() {
        return boardModel;
    }

    public void setBoardModel(Integer boardModel) {
        this.boardModel = boardModel;
    }

    public String getBoardSN() {
        return boardSN;
    }

    public void setBoardSN(String boardSN) {
        this.boardSN = boardSN;
    }

    public List<Cpu> getCpus() {
        return cpus;
    }

    public void setCpus(List<Cpu> cpus) {
        this.cpus = cpus;
    }

    public MachineBox getMachineBox() {
        return machineBox;
    }

    public void setMachineBox(MachineBox machineBox) {
        this.machineBox = machineBox;
    }
}
